class Solution {
public:
    int majorityElement(vector<int>& nums) {

        int win=nums[0],count=1;
        for(int i=1;i<nums.size();i++)
            {
            if(win==nums[i])count++;
            else count--;
            if(count==0)
                {
                win=nums[++i];
            	count++;
                }
        }
        return win;
    }
};